package tp.pr4;

/**
 * This class represents the city where the robot is wandering. 
 * It contains information about the streets and the places in the city
 * @author Alvaro Saez Hernando
 * @author Noel Clemente Montero 
 */
public class City {
	
	private Street[] cityMap; 
	
	/**
	 * Default constructor. Needed for testing purposes
	 */
	public City(){
		this.cityMap = new Street[0];
	}
	
	/**
	 * Creates a city using an array of streets
	 * @param cityMap
	 */
	public City(Street[] cityMap){
		this.cityMap = cityMap;	
	}
	
	/**
	 * Looks for the street that starts from the given place in the given direction.
	 * @param currentPlace The place where to look for the street
	 * @param currentHeading The direction to look for the street
	 * @return the street that stars from the given place in the given direction. 
	 * It returns null if there is not any street in this direction from the given place
	 */
	public Street lookForStreet(Place currentPlace,Direction currentHeading){
		int aux = this.cityMap.length;
		for(int i=0; i<aux; i++){
			if(cityMap[i].comeOutFrom(currentPlace, currentHeading)){
				return cityMap[i];
			}		
		}
		return null;
	}
	
	/**
	 * Adds an street to the city
	 * @param street The street to be added
	 */
	public void addStreet(Street street){
		this.cityMap[cityMap.length] = street;
	}
	
}
